import request from "@/utils/request";
import { AxiosPromise } from "axios";
import {WebHookQuery, WebHookForm} from "@/api/webHook/types";

/**
 * 平台分页数据
 *
 * @param queryParams
 */
export function getWebHookPage(
	queryParams: WebHookQuery
): AxiosPromise<PageResult<[]>> {
	return request({
		url: '/api/v1/webHook/page',
		method: 'get',
		params: queryParams
	});
}

/**
 * 获取平台表单数据
 *
 * @param queryParams
 */
export function getWebHookForm(id: number): AxiosPromise<WebHookForm> {
	return request({
		url: '/api/v1/webHook/' + id + '/form',
		method: 'get'
	});
}


/**
 * 保存平台
 *
 * @param data
 */
export function saveWebHook(data: WebHookForm) {
  return request({
    url: "/api/v1/webHook/saveOrUpdate",
    method: "post",
    data: data,
  });
}

/**
 * 删除平台
 *
 * @param ids
 */
export function deleteWebHook(ids: string) {
	return request({
		url: '/api/v1/webHook/' + ids,
		method: 'delete'
	});
}

/**
 * 启用webhook
 *
 * @param ids
 */
export function enableWebHook(ids: string) {
	return request({
		url: '/api/v1/webHook/enable/' + ids,
		method: 'get'
	});
}

/**
 * 禁用webhook
 *
 * @param ids
 */
export function disableWebHook(ids: string) {
	return request({
		url: '/api/v1/webHook/disable/' + ids,
		method: 'get'
	});
}
